{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "RIV-9vEqxTBB"
      },
      "source": [
        "![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n",
        "\n",
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JohnSnowLabs/nlu/blob/master/examples/colab/Training/binary_text_classification/NLU_training_sentiment_classifier_demo_apple_twitter.ipynb)\n",
        "\n",
        "\n",
        "\n",
        "# Training a Sentiment Analysis Classifier with NLU\n",
        "## 2 class Apple Tweets sentiment classifier training\n",
        "With the [SentimentDL model](https://nlp.johnsnowlabs.com/docs/en/annotators#sentimentdl-multi-class-sentiment-analysis-annotator) from Spark NLP you can achieve State Of the Art results on any multi class text classification problem\n",
        "\n",
        "This notebook showcases the following features :\n",
        "\n",
        "- How to train the deep learning classifier\n",
        "- How to store a pipeline to disk\n",
        "- How to load the pipeline from disk (Enables NLU offline mode)\n",
        "\n",
        "You can achieve these results or even better on this dataset with training data:\n",
        "\n",
        "<br>\n",
        "\n",
        "![image.png]()\n",
        "\n",
        "You can achieve these results or even better on this dataset with test data:\n",
        "\n",
        "\n",
        "\n",
        "<br>\n",
        "\n",
        "\n",
        "![image.png]()\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "05-mAOF6ol-0"
      },
      "source": [
        "!pip install -q johnsnowlabs"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "f4KkTfnR5Ugg"
      },
      "source": [
        "# 2. Download appple twitter  Sentiment dataset\n",
        "https://www.kaggle.com/seriousran/appletwittersentimenttexts\n",
        "\n",
        "this dataset contains tweets made towards apple and today we are going to train our model to predict whether the tweet contains sentiment!\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "OrVb5ZMvvrQD"
      },
      "source": [
        "! wget https://s3.amazonaws.com/auxdata.johnsnowlabs.com/public/resources/en/classifier-dl/apple-twitter/apple-twitter-sentiment-texts.csv\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 424
        },
        "id": "y4xSRWIhwT28",
        "outputId": "fd429b0f-a052-4017-e497-aa73d3566f3e"
      },
      "source": [
        "import pandas as pd\n",
        "train_path = '/content/apple-twitter-sentiment-texts.csv'\n",
        "\n",
        "train_df = pd.read_csv(train_path)\n",
        "# the text data to use for classification should be in a column named 'text'\n",
        "# the label column must have name 'y' name be of type str\n",
        "columns=['text','y']\n",
        "train_df = train_df[columns]\n",
        "train_df = train_df[~train_df[\"y\"].isin([\"neutral\"])]\n",
        "from sklearn.model_selection import train_test_split\n",
        "\n",
        "train_df, test_df = train_test_split(train_df, test_size=0.2)\n",
        "train_df"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                                                   text         y\n",
              "44    I'm surprised there isn't more talk about what...  negative\n",
              "691   over 1 hour on hold with @apple customer servi...  negative\n",
              "1371                               I'm still mad @apple  negative\n",
              "870   @jokigenki @Apple I think it's like 2011? Can'...  negative\n",
              "1226  @apple #ios8 The lack of true keyboard integra...  negative\n",
              "...                                                 ...       ...\n",
              "1392  itunes is awful &amp; is ruining my life fix y...  negative\n",
              "733   Happy Monday! My camera on my fancy @Apple #iP...  negative\n",
              "503   Phone just died while it was plug in. @apple w...  negative\n",
              "634   Whoever downgrades from a iphone 6 to a 5S obv...  negative\n",
              "891   I can't queue songs on an iPhone @apple @timco...  negative\n",
              "\n",
              "[663 rows x 2 columns]"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-6ca0d3aa-a053-4f55-83e4-30fc3b19e822\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>text</th>\n",
              "      <th>y</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>44</th>\n",
              "      <td>I'm surprised there isn't more talk about what...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>691</th>\n",
              "      <td>over 1 hour on hold with @apple customer servi...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1371</th>\n",
              "      <td>I'm still mad @apple</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>870</th>\n",
              "      <td>@jokigenki @Apple I think it's like 2011? Can'...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1226</th>\n",
              "      <td>@apple #ios8 The lack of true keyboard integra...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1392</th>\n",
              "      <td>itunes is awful &amp;amp; is ruining my life fix y...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>733</th>\n",
              "      <td>Happy Monday! My camera on my fancy @Apple #iP...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>503</th>\n",
              "      <td>Phone just died while it was plug in. @apple w...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>634</th>\n",
              "      <td>Whoever downgrades from a iphone 6 to a 5S obv...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>891</th>\n",
              "      <td>I can't queue songs on an iPhone @apple @timco...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>663 rows × 2 columns</p>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-6ca0d3aa-a053-4f55-83e4-30fc3b19e822')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-6ca0d3aa-a053-4f55-83e4-30fc3b19e822 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-6ca0d3aa-a053-4f55-83e4-30fc3b19e822');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-2cce038a-3545-432c-95d8-cce48c4cabbb\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-2cce038a-3545-432c-95d8-cce48c4cabbb')\"\n",
              "            title=\"Suggest charts.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-2cce038a-3545-432c-95d8-cce48c4cabbb button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 3
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0296Om2C5anY"
      },
      "source": [
        "# 3. Train Deep Learning Classifier using nlu.load('train.sentiment')\n",
        "\n",
        "You dataset label column should be named 'y' and the feature column with text data should be named 'text'"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "3ZIPkRkWftBG",
        "outputId": "463803c9-0441-4007-c5c1-133b15f038b4"
      },
      "source": [
        "from sklearn.metrics import classification_report\n",
        "from johnsnowlabs import nlp\n",
        "\n",
        "# load a trainable pipeline by specifying the train. prefix  and fit it on a datset with label and text columns\n",
        "# by default the Universal Sentence Encoder (USE) Sentence embeddings are used for generation\n",
        "trainable_pipe = nlp.load('train.sentiment')\n",
        "\n",
        "fitted_pipe = trainable_pipe.fit(train_df.iloc[:50])\n",
        "\n",
        "# predict with the trainable pipeline on dataset and get predictions\n",
        "preds = fitted_pipe.predict(train_df.iloc[:50],output_level='document')\n",
        "#sentence detector that is part of the pipe generates sone NaNs. lets drop them first\n",
        "preds.dropna(inplace=True)\n",
        "print(classification_report(preds['y'], preds['sentiment']))\n",
        "\n",
        "preds"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Warning::Spark Session already created, some configs may not take.\n",
            "sent_small_bert_L2_128 download started this may take some time.\n",
            "Approximate size to download 16.1 MB\n",
            "[OK!]\n",
            "              precision    recall  f1-score   support\n",
            "\n",
            "    negative       0.82      1.00      0.90        41\n",
            "    positive       0.00      0.00      0.00         9\n",
            "\n",
            "    accuracy                           0.82        50\n",
            "   macro avg       0.41      0.50      0.45        50\n",
            "weighted avg       0.67      0.82      0.74        50\n",
            "\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                                             document  \\\n",
              "0   @apple fucking let everyone name the group cha...   \n",
              "1   As a die hard @Apple customer, I must say I am...   \n",
              "2                   RT @_iamGambino: Thank you @Apple   \n",
              "3                             YO YOU AINT SHIT @apple   \n",
              "4   Theyre not RT @Naivana_: You gotta be kidding ...   \n",
              "5   My MacBook Pro is now as annoying as my ASUS W...   \n",
              "6   It's just dawned on me that I've probably spen...   \n",
              "7   Hey @apple @sprint I'm not a fan of your lates...   \n",
              "8                                 @apple y'all shitty   \n",
              "9   YO I DIDNT TOUCH MY PHONE AT ALL AND RIGHT WHE...   \n",
              "10                                        FUCK @apple   \n",
              "11  my iphone6 plus is impossible to hold without ...   \n",
              "12  @apple last time I checked I thought I bought ...   \n",
              "13  just need @apple to come out with a charger co...   \n",
              "14  RT @peterpham: Bought my @AugustSmartLock at t...   \n",
              "15  Apple's iPhone 6 Plus Amazingly Captures 41% o...   \n",
              "16  @SamJam Agreed--have to give props to @Apple f...   \n",
              "17  @jakeflem @Apple Yes It seems to fix it good t...   \n",
              "18  It shouldn't take a whole week to replace my h...   \n",
              "19  @nigxnog @Apple bruh that means u type that a ...   \n",
              "20  I don't undestand how @SYFNews #CreditCare web...   \n",
              "21  Steve Jobs Predicted Future Of E-Commerce Back...   \n",
              "22  These Damn @Apple Commercials Are Getting Wors...   \n",
              "23     Those** PICK UP THE SLACK YOU FUCK BOYS @Apple   \n",
              "24  hey @apple can I catch a fucking maverick of a...   \n",
              "25  @apple#ipad #irig For the price to connect my ...   \n",
              "26  fucking @apple are memer FAGGOTS http://t.co/w...   \n",
              "27  Safari just crashed on me and I didn't have an...   \n",
              "28  @Apple deleted users' non-#iTunes music and di...   \n",
              "29  @PCAudioLabs is in and @Apple is out at Emanon...   \n",
              "30  @jokigenki @Apple I think it's like 2011? Can'...   \n",
              "31  RT @tschwettman: hey @apple why won't you let ...   \n",
              "32  @wastwater1 l agree with you, they're about as...   \n",
              "33  How do I log into iCloud on my phone? Not the ...   \n",
              "34  Shout out to @Apple for making crappy iPhone a...   \n",
              "35  We're so excited to be named to @Apple's 'App ...   \n",
              "36  my iPhone is fucked. Thanks @apple and @EE wha...   \n",
              "37  iPhone6 fell 2 ft. Screen shattered like it wa...   \n",
              "38  CNBCTV: #Chromecast beats #AppleTV #aapl http:...   \n",
              "39  It makes you smarter. Elevate is @apple app of...   \n",
              "40  IPhone6 has too many issues, why tf is the ear...   \n",
              "41  Great time had @Apple store on Friday. @Russel...   \n",
              "42  Hey @apple are you even thinking about fixing ...   \n",
              "43  . @apple I don't think the '59' should be so c...   \n",
              "44  .@apple why do your computers like to crash on...   \n",
              "45  Ha, poor @apple trying to make its iPad and Ma...   \n",
              "46              You'll be back in my life soon @apple   \n",
              "47                 iTunes is pissing me tf off @apple   \n",
              "48                    RT @bchmura12: .@apple you suck   \n",
              "49  Updated to Yosemite on two machines. Both are ...   \n",
              "\n",
              "                 sentence_embedding_small_bert_L2_128 sentiment  \\\n",
              "0   [-1.5767942667007446, -0.2661866843700409, 0.1...  negative   \n",
              "1   [-0.1864045411348343, 0.37810075283050537, -0....  negative   \n",
              "2   [-0.39863264560699463, -0.018525924533605576, ...  negative   \n",
              "3   [-1.3272020816802979, -0.6504784226417542, -0....  negative   \n",
              "4   [-0.26906388998031616, 0.16873443126678467, 0....  negative   \n",
              "5   [-0.7138646841049194, -0.03021504543721676, 0....  negative   \n",
              "6   [-0.08956478536128998, -0.09104951471090317, -...  negative   \n",
              "7   [-0.6237524747848511, 0.10997672379016876, 0.6...  negative   \n",
              "8   [-1.721300482749939, -1.328816533088684, 0.083...  negative   \n",
              "9   [-0.7379449605941772, 0.2959931790828705, -0.4...  negative   \n",
              "10  [-1.0854371786117554, -0.38098257780075073, 0....  negative   \n",
              "11  [-0.06848365068435669, 0.4246528148651123, 0.1...  negative   \n",
              "12  [-1.1634764671325684, 0.5120655298233032, -0.0...  negative   \n",
              "13  [-0.5657770037651062, 0.8361220359802246, -0.1...  negative   \n",
              "14  [-0.43666037917137146, 0.7088866829872131, 0.4...  negative   \n",
              "15  [-0.1403159201145172, 0.65235835313797, 0.1092...  negative   \n",
              "16  [-0.2358071506023407, 0.060792725533246994, -0...  negative   \n",
              "17  [-1.220468521118164, 0.09469269961118698, -0.0...  negative   \n",
              "18  [-1.0816304683685303, 0.6302781701087952, -0.4...  negative   \n",
              "19  [-1.056034803390503, 0.15630772709846497, 0.51...  negative   \n",
              "20  [-0.6713889241218567, 0.5271422266960144, 0.07...  negative   \n",
              "21  [-0.3053719401359558, 0.9345525503158569, 0.21...  negative   \n",
              "22  [-0.8299529552459717, -0.4301386773586273, -0....  negative   \n",
              "23  [-1.3581013679504395, -0.15301916003227234, 0....  negative   \n",
              "24  [-0.6373146772384644, 0.5904020667076111, 0.28...  negative   \n",
              "25  [-0.5737035870552063, 0.6071469783782959, 0.06...  negative   \n",
              "26  [-0.04430821165442467, 0.44264474511146545, 0....  negative   \n",
              "27  [-0.32811102271080017, 0.6601451635360718, -0....  negative   \n",
              "28  [-0.3346312940120697, 0.2459762543439865, 0.54...  negative   \n",
              "29  [-0.05351848155260086, 0.6132703423500061, 0.0...  negative   \n",
              "30  [-0.9171913862228394, -0.03775791823863983, 0....  negative   \n",
              "31  [-0.8461720943450928, 0.45761561393737793, 0.1...  negative   \n",
              "32  [-0.5620263814926147, 0.1833726316690445, 0.10...  negative   \n",
              "33  [-1.0261833667755127, 0.39792588353157043, -0....  negative   \n",
              "34  [-1.0023715496063232, 0.22417372465133667, 0.0...  negative   \n",
              "35  [-0.3373744487762451, 0.1699923425912857, 0.39...  negative   \n",
              "36  [-0.6871265769004822, 0.16453255712985992, -0....  negative   \n",
              "37  [-0.38180163502693176, 0.26194843649864197, -0...  negative   \n",
              "38  [0.25390008091926575, 0.2027512639760971, 0.71...  negative   \n",
              "39  [-0.3650900721549988, -0.056419190019369125, 0...  negative   \n",
              "40  [-0.5127007961273193, 0.68586665391922, -0.193...  negative   \n",
              "41  [-0.8063774704933167, 0.4269622266292572, 0.51...  negative   \n",
              "42  [-0.9981245994567871, -0.04270806908607483, 0....  negative   \n",
              "43  [-1.193355679512024, 0.2766774296760559, -0.14...  negative   \n",
              "44  [-1.2451688051223755, -0.2248333841562271, -0....  negative   \n",
              "45  [-0.7224618196487427, 0.03269221633672714, -0....  negative   \n",
              "46  [-1.220320701599121, -0.1481868475675583, -0.3...  negative   \n",
              "47  [-1.0455917119979858, 0.08097667992115021, 0.3...  negative   \n",
              "48  [-0.9056015014648438, -0.7452876567840576, 0.6...  negative   \n",
              "49  [-0.5752751231193542, 0.05041218921542168, -0....  negative   \n",
              "\n",
              "   sentiment_confidence                                               text  \\\n",
              "0                   7.0  @apple fucking let everyone name the group cha...   \n",
              "1                   5.0  As a die hard @Apple customer, I must say I am...   \n",
              "2                   9.0                  RT @_iamGambino: Thank you @Apple   \n",
              "3                   1.0                            YO YOU AINT SHIT @apple   \n",
              "4                   3.0  Theyre not RT @Naivana_: You gotta be kidding ...   \n",
              "5                   1.0  My MacBook Pro is now as annoying as my ASUS W...   \n",
              "6                   3.0  It's just dawned on me that I've probably spen...   \n",
              "7                   3.0  Hey @apple @sprint I'm not a fan of your lates...   \n",
              "8                   1.0                                @apple y'all shitty   \n",
              "9                   8.0  YO I DIDNT TOUCH MY PHONE AT ALL AND RIGHT WHE...   \n",
              "10                  2.0                                        FUCK @apple   \n",
              "11                  1.0  my iphone6 plus is impossible to hold without ...   \n",
              "12                  1.0  @apple last time I checked I thought I bought ...   \n",
              "13                  3.0  just need @apple to come out with a charger co...   \n",
              "14                  1.0  RT @peterpham: Bought my @AugustSmartLock at t...   \n",
              "15                  2.0  Apple's iPhone 6 Plus Amazingly Captures 41% o...   \n",
              "16                  4.0  @SamJam Agreed--have to give props to @Apple f...   \n",
              "17                  2.0  @jakeflem @Apple Yes It seems to fix it good t...   \n",
              "18                  1.0  It shouldn't take a whole week to replace my h...   \n",
              "19                  1.0  @nigxnog @Apple bruh that means u type that a ...   \n",
              "20                  1.0  I don't undestand how @SYFNews #CreditCare web...   \n",
              "21                  6.0  Steve Jobs Predicted Future Of E-Commerce Back...   \n",
              "22                  4.0  These Damn @Apple Commercials Are Getting Wors...   \n",
              "23                  5.0     Those** PICK UP THE SLACK YOU FUCK BOYS @Apple   \n",
              "24                  4.0  hey @apple can I catch a fucking maverick of a...   \n",
              "25                  6.0  @apple#ipad #irig  For the price to connect my...   \n",
              "26                  2.0  fucking @apple are memer FAGGOTS http://t.co/w...   \n",
              "27                  6.0  Safari just crashed on me and I didn't have an...   \n",
              "28                  1.0  @Apple deleted users' non-#iTunes music and di...   \n",
              "29                  8.0  @PCAudioLabs is in and @Apple is out at Emanon...   \n",
              "30                  9.0  @jokigenki @Apple I think it's like 2011? Can'...   \n",
              "31                  3.0  RT @tschwettman: hey @apple why won't you let ...   \n",
              "32                  1.0  @wastwater1 l agree with you, they're about as...   \n",
              "33                  6.0  How do I log into iCloud on my phone? Not the ...   \n",
              "34                  3.0  Shout out to @Apple for making crappy iPhone a...   \n",
              "35                  3.0  We're so excited to be named to @Apple's 'App ...   \n",
              "36                  2.0  my iPhone is fucked. Thanks @apple and @EE wha...   \n",
              "37                  1.0  iPhone6 fell 2 ft. Screen shattered like it wa...   \n",
              "38                  1.0  CNBCTV:  #Chromecast beats #AppleTV #aapl http...   \n",
              "39                  4.0  It makes you smarter.  Elevate is @apple app o...   \n",
              "40                  5.0  IPhone6 has too many issues,  why tf is the ea...   \n",
              "41                  4.0  Great time had @Apple store on Friday. @Russel...   \n",
              "42                  1.0  Hey @apple are you even thinking about fixing ...   \n",
              "43                  1.0  . @apple I don't think the '59' should be so c...   \n",
              "44                  5.0  .@apple why do your computers like to crash on...   \n",
              "45                  5.0  Ha, poor @apple trying to make its iPad and Ma...   \n",
              "46                  6.0              You'll be back in my life soon @apple   \n",
              "47                  1.0                 iTunes is pissing me tf off @apple   \n",
              "48                  2.0                    RT @bchmura12: .@apple you suck   \n",
              "49                  1.0  Updated to Yosemite on two machines. Both are ...   \n",
              "\n",
              "           y  \n",
              "0   negative  \n",
              "1   negative  \n",
              "2   positive  \n",
              "3   negative  \n",
              "4   negative  \n",
              "5   negative  \n",
              "6   negative  \n",
              "7   negative  \n",
              "8   negative  \n",
              "9   negative  \n",
              "10  negative  \n",
              "11  negative  \n",
              "12  negative  \n",
              "13  negative  \n",
              "14  positive  \n",
              "15  positive  \n",
              "16  positive  \n",
              "17  negative  \n",
              "18  negative  \n",
              "19  negative  \n",
              "20  negative  \n",
              "21  positive  \n",
              "22  negative  \n",
              "23  negative  \n",
              "24  negative  \n",
              "25  negative  \n",
              "26  negative  \n",
              "27  negative  \n",
              "28  negative  \n",
              "29  negative  \n",
              "30  negative  \n",
              "31  negative  \n",
              "32  negative  \n",
              "33  negative  \n",
              "34  negative  \n",
              "35  positive  \n",
              "36  negative  \n",
              "37  negative  \n",
              "38  negative  \n",
              "39  positive  \n",
              "40  negative  \n",
              "41  positive  \n",
              "42  negative  \n",
              "43  negative  \n",
              "44  negative  \n",
              "45  negative  \n",
              "46  positive  \n",
              "47  negative  \n",
              "48  negative  \n",
              "49  negative  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-3701d116-d324-4cb7-a5af-7200b4eeb79c\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>document</th>\n",
              "      <th>sentence_embedding_small_bert_L2_128</th>\n",
              "      <th>sentiment</th>\n",
              "      <th>sentiment_confidence</th>\n",
              "      <th>text</th>\n",
              "      <th>y</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>@apple fucking let everyone name the group cha...</td>\n",
              "      <td>[-1.5767942667007446, -0.2661866843700409, 0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>7.0</td>\n",
              "      <td>@apple fucking let everyone name the group cha...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>As a die hard @Apple customer, I must say I am...</td>\n",
              "      <td>[-0.1864045411348343, 0.37810075283050537, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>5.0</td>\n",
              "      <td>As a die hard @Apple customer, I must say I am...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>RT @_iamGambino: Thank you @Apple</td>\n",
              "      <td>[-0.39863264560699463, -0.018525924533605576, ...</td>\n",
              "      <td>negative</td>\n",
              "      <td>9.0</td>\n",
              "      <td>RT @_iamGambino: Thank you @Apple</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>YO YOU AINT SHIT @apple</td>\n",
              "      <td>[-1.3272020816802979, -0.6504784226417542, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>YO YOU AINT SHIT @apple</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>Theyre not RT @Naivana_: You gotta be kidding ...</td>\n",
              "      <td>[-0.26906388998031616, 0.16873443126678467, 0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>Theyre not RT @Naivana_: You gotta be kidding ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>My MacBook Pro is now as annoying as my ASUS W...</td>\n",
              "      <td>[-0.7138646841049194, -0.03021504543721676, 0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>My MacBook Pro is now as annoying as my ASUS W...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>It's just dawned on me that I've probably spen...</td>\n",
              "      <td>[-0.08956478536128998, -0.09104951471090317, -...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>It's just dawned on me that I've probably spen...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>7</th>\n",
              "      <td>Hey @apple @sprint I'm not a fan of your lates...</td>\n",
              "      <td>[-0.6237524747848511, 0.10997672379016876, 0.6...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>Hey @apple @sprint I'm not a fan of your lates...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>8</th>\n",
              "      <td>@apple y'all shitty</td>\n",
              "      <td>[-1.721300482749939, -1.328816533088684, 0.083...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>@apple y'all shitty</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>9</th>\n",
              "      <td>YO I DIDNT TOUCH MY PHONE AT ALL AND RIGHT WHE...</td>\n",
              "      <td>[-0.7379449605941772, 0.2959931790828705, -0.4...</td>\n",
              "      <td>negative</td>\n",
              "      <td>8.0</td>\n",
              "      <td>YO I DIDNT TOUCH MY PHONE AT ALL AND RIGHT WHE...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>10</th>\n",
              "      <td>FUCK @apple</td>\n",
              "      <td>[-1.0854371786117554, -0.38098257780075073, 0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>FUCK @apple</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>11</th>\n",
              "      <td>my iphone6 plus is impossible to hold without ...</td>\n",
              "      <td>[-0.06848365068435669, 0.4246528148651123, 0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>my iphone6 plus is impossible to hold without ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>12</th>\n",
              "      <td>@apple last time I checked I thought I bought ...</td>\n",
              "      <td>[-1.1634764671325684, 0.5120655298233032, -0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>@apple last time I checked I thought I bought ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>13</th>\n",
              "      <td>just need @apple to come out with a charger co...</td>\n",
              "      <td>[-0.5657770037651062, 0.8361220359802246, -0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>just need @apple to come out with a charger co...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>14</th>\n",
              "      <td>RT @peterpham: Bought my @AugustSmartLock at t...</td>\n",
              "      <td>[-0.43666037917137146, 0.7088866829872131, 0.4...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>RT @peterpham: Bought my @AugustSmartLock at t...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>15</th>\n",
              "      <td>Apple's iPhone 6 Plus Amazingly Captures 41% o...</td>\n",
              "      <td>[-0.1403159201145172, 0.65235835313797, 0.1092...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>Apple's iPhone 6 Plus Amazingly Captures 41% o...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>16</th>\n",
              "      <td>@SamJam Agreed--have to give props to @Apple f...</td>\n",
              "      <td>[-0.2358071506023407, 0.060792725533246994, -0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>4.0</td>\n",
              "      <td>@SamJam Agreed--have to give props to @Apple f...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>17</th>\n",
              "      <td>@jakeflem @Apple Yes It seems to fix it good t...</td>\n",
              "      <td>[-1.220468521118164, 0.09469269961118698, -0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>@jakeflem @Apple Yes It seems to fix it good t...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>18</th>\n",
              "      <td>It shouldn't take a whole week to replace my h...</td>\n",
              "      <td>[-1.0816304683685303, 0.6302781701087952, -0.4...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>It shouldn't take a whole week to replace my h...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>19</th>\n",
              "      <td>@nigxnog @Apple bruh that means u type that a ...</td>\n",
              "      <td>[-1.056034803390503, 0.15630772709846497, 0.51...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>@nigxnog @Apple bruh that means u type that a ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>20</th>\n",
              "      <td>I don't undestand how @SYFNews #CreditCare web...</td>\n",
              "      <td>[-0.6713889241218567, 0.5271422266960144, 0.07...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>I don't undestand how @SYFNews #CreditCare web...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>21</th>\n",
              "      <td>Steve Jobs Predicted Future Of E-Commerce Back...</td>\n",
              "      <td>[-0.3053719401359558, 0.9345525503158569, 0.21...</td>\n",
              "      <td>negative</td>\n",
              "      <td>6.0</td>\n",
              "      <td>Steve Jobs Predicted Future Of E-Commerce Back...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>22</th>\n",
              "      <td>These Damn @Apple Commercials Are Getting Wors...</td>\n",
              "      <td>[-0.8299529552459717, -0.4301386773586273, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>4.0</td>\n",
              "      <td>These Damn @Apple Commercials Are Getting Wors...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>23</th>\n",
              "      <td>Those** PICK UP THE SLACK YOU FUCK BOYS @Apple</td>\n",
              "      <td>[-1.3581013679504395, -0.15301916003227234, 0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>5.0</td>\n",
              "      <td>Those** PICK UP THE SLACK YOU FUCK BOYS @Apple</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>24</th>\n",
              "      <td>hey @apple can I catch a fucking maverick of a...</td>\n",
              "      <td>[-0.6373146772384644, 0.5904020667076111, 0.28...</td>\n",
              "      <td>negative</td>\n",
              "      <td>4.0</td>\n",
              "      <td>hey @apple can I catch a fucking maverick of a...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>25</th>\n",
              "      <td>@apple#ipad #irig For the price to connect my ...</td>\n",
              "      <td>[-0.5737035870552063, 0.6071469783782959, 0.06...</td>\n",
              "      <td>negative</td>\n",
              "      <td>6.0</td>\n",
              "      <td>@apple#ipad #irig  For the price to connect my...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>26</th>\n",
              "      <td>fucking @apple are memer FAGGOTS http://t.co/w...</td>\n",
              "      <td>[-0.04430821165442467, 0.44264474511146545, 0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>fucking @apple are memer FAGGOTS http://t.co/w...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>27</th>\n",
              "      <td>Safari just crashed on me and I didn't have an...</td>\n",
              "      <td>[-0.32811102271080017, 0.6601451635360718, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>6.0</td>\n",
              "      <td>Safari just crashed on me and I didn't have an...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>28</th>\n",
              "      <td>@Apple deleted users' non-#iTunes music and di...</td>\n",
              "      <td>[-0.3346312940120697, 0.2459762543439865, 0.54...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>@Apple deleted users' non-#iTunes music and di...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>29</th>\n",
              "      <td>@PCAudioLabs is in and @Apple is out at Emanon...</td>\n",
              "      <td>[-0.05351848155260086, 0.6132703423500061, 0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>8.0</td>\n",
              "      <td>@PCAudioLabs is in and @Apple is out at Emanon...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>30</th>\n",
              "      <td>@jokigenki @Apple I think it's like 2011? Can'...</td>\n",
              "      <td>[-0.9171913862228394, -0.03775791823863983, 0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>9.0</td>\n",
              "      <td>@jokigenki @Apple I think it's like 2011? Can'...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>31</th>\n",
              "      <td>RT @tschwettman: hey @apple why won't you let ...</td>\n",
              "      <td>[-0.8461720943450928, 0.45761561393737793, 0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>RT @tschwettman: hey @apple why won't you let ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>32</th>\n",
              "      <td>@wastwater1 l agree with you, they're about as...</td>\n",
              "      <td>[-0.5620263814926147, 0.1833726316690445, 0.10...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>@wastwater1 l agree with you, they're about as...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>33</th>\n",
              "      <td>How do I log into iCloud on my phone? Not the ...</td>\n",
              "      <td>[-1.0261833667755127, 0.39792588353157043, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>6.0</td>\n",
              "      <td>How do I log into iCloud on my phone? Not the ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>34</th>\n",
              "      <td>Shout out to @Apple for making crappy iPhone a...</td>\n",
              "      <td>[-1.0023715496063232, 0.22417372465133667, 0.0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>Shout out to @Apple for making crappy iPhone a...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>35</th>\n",
              "      <td>We're so excited to be named to @Apple's 'App ...</td>\n",
              "      <td>[-0.3373744487762451, 0.1699923425912857, 0.39...</td>\n",
              "      <td>negative</td>\n",
              "      <td>3.0</td>\n",
              "      <td>We're so excited to be named to @Apple's 'App ...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>36</th>\n",
              "      <td>my iPhone is fucked. Thanks @apple and @EE wha...</td>\n",
              "      <td>[-0.6871265769004822, 0.16453255712985992, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>my iPhone is fucked. Thanks @apple and @EE wha...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>37</th>\n",
              "      <td>iPhone6 fell 2 ft. Screen shattered like it wa...</td>\n",
              "      <td>[-0.38180163502693176, 0.26194843649864197, -0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>iPhone6 fell 2 ft. Screen shattered like it wa...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>38</th>\n",
              "      <td>CNBCTV: #Chromecast beats #AppleTV #aapl http:...</td>\n",
              "      <td>[0.25390008091926575, 0.2027512639760971, 0.71...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>CNBCTV:  #Chromecast beats #AppleTV #aapl http...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>39</th>\n",
              "      <td>It makes you smarter. Elevate is @apple app of...</td>\n",
              "      <td>[-0.3650900721549988, -0.056419190019369125, 0...</td>\n",
              "      <td>negative</td>\n",
              "      <td>4.0</td>\n",
              "      <td>It makes you smarter.  Elevate is @apple app o...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>40</th>\n",
              "      <td>IPhone6 has too many issues, why tf is the ear...</td>\n",
              "      <td>[-0.5127007961273193, 0.68586665391922, -0.193...</td>\n",
              "      <td>negative</td>\n",
              "      <td>5.0</td>\n",
              "      <td>IPhone6 has too many issues,  why tf is the ea...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>41</th>\n",
              "      <td>Great time had @Apple store on Friday. @Russel...</td>\n",
              "      <td>[-0.8063774704933167, 0.4269622266292572, 0.51...</td>\n",
              "      <td>negative</td>\n",
              "      <td>4.0</td>\n",
              "      <td>Great time had @Apple store on Friday. @Russel...</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>42</th>\n",
              "      <td>Hey @apple are you even thinking about fixing ...</td>\n",
              "      <td>[-0.9981245994567871, -0.04270806908607483, 0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>Hey @apple are you even thinking about fixing ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>43</th>\n",
              "      <td>. @apple I don't think the '59' should be so c...</td>\n",
              "      <td>[-1.193355679512024, 0.2766774296760559, -0.14...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>. @apple I don't think the '59' should be so c...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>44</th>\n",
              "      <td>.@apple why do your computers like to crash on...</td>\n",
              "      <td>[-1.2451688051223755, -0.2248333841562271, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>5.0</td>\n",
              "      <td>.@apple why do your computers like to crash on...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>45</th>\n",
              "      <td>Ha, poor @apple trying to make its iPad and Ma...</td>\n",
              "      <td>[-0.7224618196487427, 0.03269221633672714, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>5.0</td>\n",
              "      <td>Ha, poor @apple trying to make its iPad and Ma...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>46</th>\n",
              "      <td>You'll be back in my life soon @apple</td>\n",
              "      <td>[-1.220320701599121, -0.1481868475675583, -0.3...</td>\n",
              "      <td>negative</td>\n",
              "      <td>6.0</td>\n",
              "      <td>You'll be back in my life soon @apple</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>47</th>\n",
              "      <td>iTunes is pissing me tf off @apple</td>\n",
              "      <td>[-1.0455917119979858, 0.08097667992115021, 0.3...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>iTunes is pissing me tf off @apple</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>48</th>\n",
              "      <td>RT @bchmura12: .@apple you suck</td>\n",
              "      <td>[-0.9056015014648438, -0.7452876567840576, 0.6...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "      <td>RT @bchmura12: .@apple you suck</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>49</th>\n",
              "      <td>Updated to Yosemite on two machines. Both are ...</td>\n",
              "      <td>[-0.5752751231193542, 0.05041218921542168, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>Updated to Yosemite on two machines. Both are ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-3701d116-d324-4cb7-a5af-7200b4eeb79c')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-3701d116-d324-4cb7-a5af-7200b4eeb79c button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-3701d116-d324-4cb7-a5af-7200b4eeb79c');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-17f6d7eb-6cae-486a-96d4-73997f6c2d18\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-17f6d7eb-6cae-486a-96d4-73997f6c2d18')\"\n",
              "            title=\"Suggest charts.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-17f6d7eb-6cae-486a-96d4-73997f6c2d18 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 3
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "lVyOE2wV0fw_"
      },
      "source": [
        "#4.  Test the fitted pipe on new example"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qdCUg2MR0PD2",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 150
        },
        "outputId": "40c2a76d-9bf9-4b99-e4fe-6db107e98c60"
      },
      "source": [
        "fitted_pipe.predict('I hate the newest update')"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "sentence_detector_dl download started this may take some time.\n",
            "Approximate size to download 354.6 KB\n",
            "[OK!]\n",
            "Warning::Spark Session already created, some configs may not take.\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                   sentence  \\\n",
              "0  I hate the newest update   \n",
              "\n",
              "                sentence_embedding_small_bert_L2_128 sentiment  \\\n",
              "0  [-1.3662102222442627, 0.10369864851236343, -0....  negative   \n",
              "\n",
              "  sentiment_confidence  \n",
              "0                  1.0  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-c545c4c1-7fcb-4057-b9e5-23d485eaec9d\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>sentence</th>\n",
              "      <th>sentence_embedding_small_bert_L2_128</th>\n",
              "      <th>sentiment</th>\n",
              "      <th>sentiment_confidence</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>I hate the newest update</td>\n",
              "      <td>[-1.3662102222442627, 0.10369864851236343, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-c545c4c1-7fcb-4057-b9e5-23d485eaec9d')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-c545c4c1-7fcb-4057-b9e5-23d485eaec9d button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-c545c4c1-7fcb-4057-b9e5-23d485eaec9d');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 4
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "xflpwrVjjBVD"
      },
      "source": [
        "##5.  Configure pipe training parameters"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "UtsAUGTmOTms",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "b831ec66-c65f-40f8-af41-e5c00fc87ee9"
      },
      "source": [
        "trainable_pipe.print_info()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The following parameters are configurable for this NLU pipeline (You can copy paste the examples) :\n",
            ">>> component_list['bert_sentence_embeddings@sent_small_bert_L2_128'] has settable params:\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setBatchSize(8)              | Info: Size of every batch | Currently set to : 8\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setEngine('tensorflow')      | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setIsLong(False)             | Info: Use Long type instead of Int type for inputs buffer - Some Bert models require Long instead of Int. | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setMaxSentenceLength(128)    | Info: Max sentence length to process | Currently set to : 128\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setDimension(128)            | Info: Number of embedding dimensions | Currently set to : 128\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setCaseSensitive(False)      | Info: whether to ignore case in tokens for embeddings matching | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setStorageRef('sent_small_bert_L2_128')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L2_128\n",
            ">>> component_list['document_assembler'] has settable params:\n",
            "component_list['document_assembler'].setCleanupMode('shrink')                                  | Info: possible values: disabled, inplace, inplace_full, shrink, shrink_full, each, each_full, delete_full | Currently set to : shrink\n",
            ">>> component_list['sentiment_dl@sent_small_bert_L2_128'] has settable params:\n",
            "component_list['sentiment_dl@sent_small_bert_L2_128'].setEngine('tensorflow')                  | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
            "component_list['sentiment_dl@sent_small_bert_L2_128'].setThreshold(0.6)                        | Info: The minimum threshold for the final result otheriwse it will be neutral | Currently set to : 0.6\n",
            "component_list['sentiment_dl@sent_small_bert_L2_128'].setThresholdLabel('neutral')             | Info: In case the score is less than threshold, what should be the label. Default is neutral. | Currently set to : neutral\n",
            "component_list['sentiment_dl@sent_small_bert_L2_128'].setStorageRef('sent_small_bert_L2_128')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L2_128\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "2GJdDNV9jEIe"
      },
      "source": [
        "##6.  Retrain with new parameters"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mptfvHx-MMMX",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 736
        },
        "outputId": "a465590a-6409-4699-93df-734cc3ecde79"
      },
      "source": [
        "# Train longer!\n",
        "trainable_pipe = nlp.load('train.sentiment')\n",
        "trainable_pipe['trainable_sentiment_dl'].setMaxEpochs(5)\n",
        "fitted_pipe = trainable_pipe.fit(train_df.iloc[:100])\n",
        "# predict with the trainable pipeline on dataset and get predictions\n",
        "preds = fitted_pipe.predict(train_df.iloc[:100],output_level='document')\n",
        "\n",
        "#sentence detector that is part of the pipe generates sone NaNs. lets drop them first\n",
        "preds.dropna(inplace=True)\n",
        "print(classification_report(preds['y'], preds['sentiment']))\n",
        "\n",
        "preds"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n",
            "sent_small_bert_L2_128 download started this may take some time.\n",
            "Approximate size to download 16.1 MB\n",
            "[OK!]\n",
            "              precision    recall  f1-score   support\n",
            "\n",
            "    negative       0.82      1.00      0.90        82\n",
            "    positive       0.00      0.00      0.00        18\n",
            "\n",
            "    accuracy                           0.82       100\n",
            "   macro avg       0.41      0.50      0.45       100\n",
            "weighted avg       0.67      0.82      0.74       100\n",
            "\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                                             document  \\\n",
              "0   @apple fucking let everyone name the group cha...   \n",
              "1   As a die hard @Apple customer, I must say I am...   \n",
              "2                   RT @_iamGambino: Thank you @Apple   \n",
              "3                             YO YOU AINT SHIT @apple   \n",
              "4   Theyre not RT @Naivana_: You gotta be kidding ...   \n",
              "..                                                ...   \n",
              "95           @Apple you need to sort your phones out.   \n",
              "96  Hey @apple, fuck you for thinking I want text ...   \n",
              "97                              @Apple honestly sucks   \n",
              "98  How long does it really take for a phone to sh...   \n",
              "99  @whereiscooldude @Cyrus_T_Virus @Apple wait no...   \n",
              "\n",
              "                 sentence_embedding_small_bert_L2_128 sentiment  \\\n",
              "0   [-1.5767942667007446, -0.2661866843700409, 0.1...  negative   \n",
              "1   [-0.1864045411348343, 0.37810075283050537, -0....  negative   \n",
              "2   [-0.39863264560699463, -0.018525924533605576, ...  negative   \n",
              "3   [-1.3272020816802979, -0.6504784226417542, -0....  negative   \n",
              "4   [-0.26906388998031616, 0.16873443126678467, 0....  negative   \n",
              "..                                                ...       ...   \n",
              "95  [-0.788460910320282, 0.194553405046463, 0.0300...  negative   \n",
              "96  [-0.7153223752975464, -0.0814858004450798, 0.2...  negative   \n",
              "97  [-1.2007137537002563, -1.1623204946517944, 0.1...  negative   \n",
              "98  [-0.9548358917236328, 0.6761127710342407, -0.1...  negative   \n",
              "99  [-1.06529700756073, -0.23610278964042664, -0.4...  negative   \n",
              "\n",
              "   sentiment_confidence                                               text  \\\n",
              "0                   1.0  @apple fucking let everyone name the group cha...   \n",
              "1                   1.0  As a die hard @Apple customer, I must say I am...   \n",
              "2                   1.0                  RT @_iamGambino: Thank you @Apple   \n",
              "3                   1.0                            YO YOU AINT SHIT @apple   \n",
              "4                   1.0  Theyre not RT @Naivana_: You gotta be kidding ...   \n",
              "..                  ...                                                ...   \n",
              "95                  1.0          @Apple  you need to sort your phones out.   \n",
              "96                  1.0  Hey @apple, fuck you for thinking I want text ...   \n",
              "97                  1.0                              @Apple honestly sucks   \n",
              "98                  1.0  How long does it really take for a phone to sh...   \n",
              "99                  1.0  @whereiscooldude @Cyrus_T_Virus @Apple wait no...   \n",
              "\n",
              "           y  \n",
              "0   negative  \n",
              "1   negative  \n",
              "2   positive  \n",
              "3   negative  \n",
              "4   negative  \n",
              "..       ...  \n",
              "95  negative  \n",
              "96  negative  \n",
              "97  negative  \n",
              "98  negative  \n",
              "99  negative  \n",
              "\n",
              "[100 rows x 6 columns]"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-7f3ebf1b-37fd-44c8-8d7a-7ca0f16cfdc4\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>document</th>\n",
              "      <th>sentence_embedding_small_bert_L2_128</th>\n",
              "      <th>sentiment</th>\n",
              "      <th>sentiment_confidence</th>\n",
              "      <th>text</th>\n",
              "      <th>y</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>@apple fucking let everyone name the group cha...</td>\n",
              "      <td>[-1.5767942667007446, -0.2661866843700409, 0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>@apple fucking let everyone name the group cha...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>As a die hard @Apple customer, I must say I am...</td>\n",
              "      <td>[-0.1864045411348343, 0.37810075283050537, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>As a die hard @Apple customer, I must say I am...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>RT @_iamGambino: Thank you @Apple</td>\n",
              "      <td>[-0.39863264560699463, -0.018525924533605576, ...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>RT @_iamGambino: Thank you @Apple</td>\n",
              "      <td>positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>YO YOU AINT SHIT @apple</td>\n",
              "      <td>[-1.3272020816802979, -0.6504784226417542, -0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>YO YOU AINT SHIT @apple</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>Theyre not RT @Naivana_: You gotta be kidding ...</td>\n",
              "      <td>[-0.26906388998031616, 0.16873443126678467, 0....</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>Theyre not RT @Naivana_: You gotta be kidding ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>95</th>\n",
              "      <td>@Apple you need to sort your phones out.</td>\n",
              "      <td>[-0.788460910320282, 0.194553405046463, 0.0300...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>@Apple  you need to sort your phones out.</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>96</th>\n",
              "      <td>Hey @apple, fuck you for thinking I want text ...</td>\n",
              "      <td>[-0.7153223752975464, -0.0814858004450798, 0.2...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>Hey @apple, fuck you for thinking I want text ...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>97</th>\n",
              "      <td>@Apple honestly sucks</td>\n",
              "      <td>[-1.2007137537002563, -1.1623204946517944, 0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>@Apple honestly sucks</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>98</th>\n",
              "      <td>How long does it really take for a phone to sh...</td>\n",
              "      <td>[-0.9548358917236328, 0.6761127710342407, -0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>How long does it really take for a phone to sh...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>99</th>\n",
              "      <td>@whereiscooldude @Cyrus_T_Virus @Apple wait no...</td>\n",
              "      <td>[-1.06529700756073, -0.23610278964042664, -0.4...</td>\n",
              "      <td>negative</td>\n",
              "      <td>1.0</td>\n",
              "      <td>@whereiscooldude @Cyrus_T_Virus @Apple wait no...</td>\n",
              "      <td>negative</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>100 rows × 6 columns</p>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-7f3ebf1b-37fd-44c8-8d7a-7ca0f16cfdc4')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-7f3ebf1b-37fd-44c8-8d7a-7ca0f16cfdc4 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-7f3ebf1b-37fd-44c8-8d7a-7ca0f16cfdc4');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-196683ef-4101-4dcc-8030-96dac9908826\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-196683ef-4101-4dcc-8030-96dac9908826')\"\n",
              "            title=\"Suggest charts.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-196683ef-4101-4dcc-8030-96dac9908826 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 6
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qFoT-s1MjTSS"
      },
      "source": [
        "#7. Try training with different Embeddings"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "nxWFzQOhjWC8",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "4df8af5e-3076-43eb-cb0e-d2e0799f602e"
      },
      "source": [
        "# We can use nlu.print_components(action='embed_sentence') to see every possibler sentence embedding we could use. Lets use bert!\n",
        "nlp.nlu.print_components(action='embed_sentence')"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "For language <am> NLU provides the following Models : \n",
            "nlu.load('am.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_amharic\n",
            "For language <de> NLU provides the following Models : \n",
            "nlu.load('de.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "For language <el> NLU provides the following Models : \n",
            "nlu.load('el.embed_sentence.bert.base_uncased') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
            "For language <en> NLU provides the following Models : \n",
            "nlu.load('en.embed_sentence') returns Spark NLP model_anno_obj tfhub_use\n",
            "nlu.load('en.embed_sentence.albert') returns Spark NLP model_anno_obj albert_base_uncased\n",
            "nlu.load('en.embed_sentence.bert') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
            "nlu.load('en.embed_sentence.bert.base_uncased_legal') returns Spark NLP model_anno_obj sent_bert_base_uncased_legal\n",
            "nlu.load('en.embed_sentence.bert.finetuned') returns Spark NLP model_anno_obj sbert_setfit_finetuned_financial_text_classification\n",
            "nlu.load('en.embed_sentence.bert.pubmed') returns Spark NLP model_anno_obj sent_bert_pubmed\n",
            "nlu.load('en.embed_sentence.bert.pubmed_squad2') returns Spark NLP model_anno_obj sent_bert_pubmed_squad2\n",
            "nlu.load('en.embed_sentence.bert.wiki_books') returns Spark NLP model_anno_obj sent_bert_wiki_books\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_mnli') returns Spark NLP model_anno_obj sent_bert_wiki_books_mnli\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_qnli') returns Spark NLP model_anno_obj sent_bert_wiki_books_qnli\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_qqp') returns Spark NLP model_anno_obj sent_bert_wiki_books_qqp\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_squad2') returns Spark NLP model_anno_obj sent_bert_wiki_books_squad2\n",
            "nlu.load('en.embed_sentence.bert.wiki_books_sst2') returns Spark NLP model_anno_obj sent_bert_wiki_books_sst2\n",
            "nlu.load('en.embed_sentence.bert_base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "nlu.load('en.embed_sentence.bert_base_uncased') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
            "nlu.load('en.embed_sentence.bert_large_cased') returns Spark NLP model_anno_obj sent_bert_large_cased\n",
            "nlu.load('en.embed_sentence.bert_large_uncased') returns Spark NLP model_anno_obj sent_bert_large_uncased\n",
            "nlu.load('en.embed_sentence.bert_use_cmlm_en_base') returns Spark NLP model_anno_obj sent_bert_use_cmlm_en_base\n",
            "nlu.load('en.embed_sentence.bert_use_cmlm_en_large') returns Spark NLP model_anno_obj sent_bert_use_cmlm_en_large\n",
            "nlu.load('en.embed_sentence.biobert.clinical_base_cased') returns Spark NLP model_anno_obj sent_biobert_clinical_base_cased\n",
            "nlu.load('en.embed_sentence.biobert.discharge_base_cased') returns Spark NLP model_anno_obj sent_biobert_discharge_base_cased\n",
            "nlu.load('en.embed_sentence.biobert.pmc_base_cased') returns Spark NLP model_anno_obj sent_biobert_pmc_base_cased\n",
            "nlu.load('en.embed_sentence.biobert.pubmed_base_cased') returns Spark NLP model_anno_obj sent_biobert_pubmed_base_cased\n",
            "nlu.load('en.embed_sentence.biobert.pubmed_large_cased') returns Spark NLP model_anno_obj sent_biobert_pubmed_large_cased\n",
            "nlu.load('en.embed_sentence.biobert.pubmed_pmc_base_cased') returns Spark NLP model_anno_obj sent_biobert_pubmed_pmc_base_cased\n",
            "nlu.load('en.embed_sentence.covidbert.large_uncased') returns Spark NLP model_anno_obj sent_covidbert_large_uncased\n",
            "nlu.load('en.embed_sentence.distil_roberta.distilled_base') returns Spark NLP model_anno_obj sent_distilroberta_base\n",
            "nlu.load('en.embed_sentence.doc2vec') returns Spark NLP model_anno_obj doc2vec_gigaword_300\n",
            "nlu.load('en.embed_sentence.doc2vec.gigaword_300') returns Spark NLP model_anno_obj doc2vec_gigaword_300\n",
            "nlu.load('en.embed_sentence.doc2vec.gigaword_wiki_300') returns Spark NLP model_anno_obj doc2vec_gigaword_wiki_300\n",
            "nlu.load('en.embed_sentence.electra') returns Spark NLP model_anno_obj sent_electra_small_uncased\n",
            "nlu.load('en.embed_sentence.electra_base_uncased') returns Spark NLP model_anno_obj sent_electra_base_uncased\n",
            "nlu.load('en.embed_sentence.electra_large_uncased') returns Spark NLP model_anno_obj sent_electra_large_uncased\n",
            "nlu.load('en.embed_sentence.electra_small_uncased') returns Spark NLP model_anno_obj sent_electra_small_uncased\n",
            "nlu.load('en.embed_sentence.roberta.base') returns Spark NLP model_anno_obj sent_roberta_base\n",
            "nlu.load('en.embed_sentence.roberta.large') returns Spark NLP model_anno_obj sent_roberta_large\n",
            "nlu.load('en.embed_sentence.small_bert_L10_128') returns Spark NLP model_anno_obj sent_small_bert_L10_128\n",
            "nlu.load('en.embed_sentence.small_bert_L10_256') returns Spark NLP model_anno_obj sent_small_bert_L10_256\n",
            "nlu.load('en.embed_sentence.small_bert_L10_512') returns Spark NLP model_anno_obj sent_small_bert_L10_512\n",
            "nlu.load('en.embed_sentence.small_bert_L10_768') returns Spark NLP model_anno_obj sent_small_bert_L10_768\n",
            "nlu.load('en.embed_sentence.small_bert_L12_128') returns Spark NLP model_anno_obj sent_small_bert_L12_128\n",
            "nlu.load('en.embed_sentence.small_bert_L12_256') returns Spark NLP model_anno_obj sent_small_bert_L12_256\n",
            "nlu.load('en.embed_sentence.small_bert_L12_512') returns Spark NLP model_anno_obj sent_small_bert_L12_512\n",
            "nlu.load('en.embed_sentence.small_bert_L12_768') returns Spark NLP model_anno_obj sent_small_bert_L12_768\n",
            "nlu.load('en.embed_sentence.small_bert_L2_128') returns Spark NLP model_anno_obj sent_small_bert_L2_128\n",
            "nlu.load('en.embed_sentence.small_bert_L2_256') returns Spark NLP model_anno_obj sent_small_bert_L2_256\n",
            "nlu.load('en.embed_sentence.small_bert_L2_512') returns Spark NLP model_anno_obj sent_small_bert_L2_512\n",
            "nlu.load('en.embed_sentence.small_bert_L2_768') returns Spark NLP model_anno_obj sent_small_bert_L2_768\n",
            "nlu.load('en.embed_sentence.small_bert_L4_128') returns Spark NLP model_anno_obj sent_small_bert_L4_128\n",
            "nlu.load('en.embed_sentence.small_bert_L4_256') returns Spark NLP model_anno_obj sent_small_bert_L4_256\n",
            "nlu.load('en.embed_sentence.small_bert_L4_512') returns Spark NLP model_anno_obj sent_small_bert_L4_512\n",
            "nlu.load('en.embed_sentence.small_bert_L4_768') returns Spark NLP model_anno_obj sent_small_bert_L4_768\n",
            "nlu.load('en.embed_sentence.small_bert_L6_128') returns Spark NLP model_anno_obj sent_small_bert_L6_128\n",
            "nlu.load('en.embed_sentence.small_bert_L6_256') returns Spark NLP model_anno_obj sent_small_bert_L6_256\n",
            "nlu.load('en.embed_sentence.small_bert_L6_512') returns Spark NLP model_anno_obj sent_small_bert_L6_512\n",
            "nlu.load('en.embed_sentence.small_bert_L6_768') returns Spark NLP model_anno_obj sent_small_bert_L6_768\n",
            "nlu.load('en.embed_sentence.small_bert_L8_128') returns Spark NLP model_anno_obj sent_small_bert_L8_128\n",
            "nlu.load('en.embed_sentence.small_bert_L8_256') returns Spark NLP model_anno_obj sent_small_bert_L8_256\n",
            "nlu.load('en.embed_sentence.small_bert_L8_512') returns Spark NLP model_anno_obj sent_small_bert_L8_512\n",
            "nlu.load('en.embed_sentence.small_bert_L8_768') returns Spark NLP model_anno_obj sent_small_bert_L8_768\n",
            "nlu.load('en.embed_sentence.tfhub_use') returns Spark NLP model_anno_obj tfhub_use\n",
            "nlu.load('en.embed_sentence.tfhub_use.lg') returns Spark NLP model_anno_obj tfhub_use_lg\n",
            "nlu.load('en.embed_sentence.use') returns Spark NLP model_anno_obj tfhub_use\n",
            "nlu.load('en.embed_sentence.use.lg') returns Spark NLP model_anno_obj tfhub_use_lg\n",
            "For language <es> NLU provides the following Models : \n",
            "nlu.load('es.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "nlu.load('es.embed_sentence.bert.base_uncased') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
            "For language <fi> NLU provides the following Models : \n",
            "nlu.load('fi.embed_sentence.bert') returns Spark NLP model_anno_obj bert_base_finnish_uncased\n",
            "nlu.load('fi.embed_sentence.bert.cased') returns Spark NLP model_anno_obj bert_base_finnish_cased\n",
            "nlu.load('fi.embed_sentence.bert.uncased') returns Spark NLP model_anno_obj bert_base_finnish_uncased\n",
            "For language <ha> NLU provides the following Models : \n",
            "nlu.load('ha.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_hausa\n",
            "For language <ig> NLU provides the following Models : \n",
            "nlu.load('ig.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_igbo\n",
            "For language <lg> NLU provides the following Models : \n",
            "nlu.load('lg.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_luganda\n",
            "For language <nl> NLU provides the following Models : \n",
            "nlu.load('nl.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "For language <pcm> NLU provides the following Models : \n",
            "nlu.load('pcm.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_naija\n",
            "For language <pt> NLU provides the following Models : \n",
            "nlu.load('pt.embed_sentence.bert.base_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_base_tsdae_sts\n",
            "nlu.load('pt.embed_sentence.bert.cased_large_legal') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.1\n",
            "nlu.load('pt.embed_sentence.bert.large_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_gpl_sts\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.10.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.10\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.2.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.2\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.3.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.3\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.4.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.4\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.5.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.5\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.7.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.7\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.8.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.8\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.9.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.9\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v1.0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v1.0\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_gpl_nli_sts_v0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_gpl_nli_sts_v0\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_gpl_nli_sts_v1.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_gpl_nli_sts_v1\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_nli_sts_v0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_nli_sts_v0\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_nli_sts_v1.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_nli_sts_v1\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_sts_v0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_sts_v0\n",
            "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_sts_v1.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_sts_v1\n",
            "nlu.load('pt.embed_sentence.bert.v2_base_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_base_ma_v2\n",
            "nlu.load('pt.embed_sentence.bert.v2_large_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_sts_v2\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.assin.base.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_base_ma\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.assin2.base.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_base\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_sts_by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_sts_ma.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large_ma\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_sts_ma_v3.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large_ma_v3\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_tsdae_sts.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_sts\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_tsdae_sts_v4.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_sts_v4\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.large_tsdae_v4_gpl_sts.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_v4_gpl_sts\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.v2_large_sts_v2.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large_v2\n",
            "nlu.load('pt.embed_sentence.bertimbau.legal.v2_large_v2_sts.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_v2_sts\n",
            "For language <rw> NLU provides the following Models : \n",
            "nlu.load('rw.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_kinyarwanda\n",
            "For language <sv> NLU provides the following Models : \n",
            "nlu.load('sv.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
            "For language <sw> NLU provides the following Models : \n",
            "nlu.load('sw.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_swahili\n",
            "For language <wo> NLU provides the following Models : \n",
            "nlu.load('wo.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_wolof\n",
            "For language <xx> NLU provides the following Models : \n",
            "nlu.load('xx.embed_sentence') returns Spark NLP model_anno_obj sent_bert_multi_cased\n",
            "nlu.load('xx.embed_sentence.bert') returns Spark NLP model_anno_obj sent_bert_multi_cased\n",
            "nlu.load('xx.embed_sentence.bert.cased') returns Spark NLP model_anno_obj sent_bert_multi_cased\n",
            "nlu.load('xx.embed_sentence.bert.muril') returns Spark NLP model_anno_obj sent_bert_muril\n",
            "nlu.load('xx.embed_sentence.bert_use_cmlm_multi_base') returns Spark NLP model_anno_obj sent_bert_use_cmlm_multi_base\n",
            "nlu.load('xx.embed_sentence.bert_use_cmlm_multi_base_br') returns Spark NLP model_anno_obj sent_bert_use_cmlm_multi_base_br\n",
            "nlu.load('xx.embed_sentence.labse') returns Spark NLP model_anno_obj labse\n",
            "nlu.load('xx.embed_sentence.xlm_roberta.base') returns Spark NLP model_anno_obj sent_xlm_roberta_base\n",
            "For language <yo> NLU provides the following Models : \n",
            "nlu.load('yo.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_yoruba\n",
            "For language <zh> NLU provides the following Models : \n",
            "nlu.load('zh.embed_sentence.bert') returns Spark NLP model_anno_obj sbert_chinese_qmc_finance_v1\n",
            "nlu.load('zh.embed_sentence.bert.distilled') returns Spark NLP model_anno_obj sbert_chinese_qmc_finance_v1_distill\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "eLex095goHwm",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "b860cf26-d169-410a-931c-57d98997255f"
      },
      "source": [
        "trainable_pipe = nlp.load('en.embed_sentence.small_bert_L12_768 train.sentiment')\n",
        "# We need to train longer and user smaller LR for NON-USE based sentence embeddings usually\n",
        "# We could tune the hyperparameters further with hyperparameter tuning methods like gridsearch\n",
        "# Also longer training gives more accuracy\n",
        "trainable_pipe['trainable_sentiment_dl'].setMaxEpochs(110)\n",
        "trainable_pipe['trainable_sentiment_dl'].setLr(0.0005)\n",
        "fitted_pipe = trainable_pipe.fit(train_df)\n",
        "# predict with the trainable pipeline on dataset and get predictions\n",
        "preds = fitted_pipe.predict(train_df,output_level='document')\n",
        "\n",
        "#sentence detector that is part of the pipe generates sone NaNs. lets drop them first\n",
        "preds.dropna(inplace=True)\n",
        "print(classification_report(preds['y'], preds['sentiment']))\n",
        "\n",
        "#preds"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n",
            "sent_small_bert_L12_768 download started this may take some time.\n",
            "Approximate size to download 392.9 MB\n",
            "[OK!]\n",
            "              precision    recall  f1-score   support\n",
            "\n",
            "    negative       0.83      1.00      0.91       551\n",
            "    positive       0.00      0.00      0.00       112\n",
            "\n",
            "    accuracy                           0.83       663\n",
            "   macro avg       0.42      0.50      0.45       663\n",
            "weighted avg       0.69      0.83      0.75       663\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "_1jxw3GnVGlI"
      },
      "source": [
        "# 7.1 evaluate on Test Data"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Fxx4yNkNVGFl",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "073133f0-e3be-4d87-c114-bc0c0a6d21e1"
      },
      "source": [
        "preds = fitted_pipe.predict(test_df,output_level='document')\n",
        "\n",
        "#sentence detector that is part of the pipe generates sone NaNs. lets drop them first\n",
        "preds.dropna(inplace=True)\n",
        "print(classification_report(preds['y'], preds['sentiment']))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "              precision    recall  f1-score   support\n",
            "\n",
            "    negative       0.81      1.00      0.90       135\n",
            "    positive       0.00      0.00      0.00        31\n",
            "\n",
            "    accuracy                           0.81       166\n",
            "   macro avg       0.41      0.50      0.45       166\n",
            "weighted avg       0.66      0.81      0.73       166\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "2BB-NwZUoHSe"
      },
      "source": [
        "# 8. Lets save the model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "bZZpObLOtqo8"
      },
      "source": [
        "stored_model_path = './models/classifier_dl_trained'\n",
        "fitted_pipe.save(stored_model_path)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "e_b2DPd4rCiU"
      },
      "source": [
        "# 9. Lets load the model from HDD.\n",
        "This makes Offlien NLU usage possible!   \n",
        "You need to call nlu.load(path=path_to_the_pipe) to load a model/pipeline from disk."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "SO4uz45MoRgp",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 133
        },
        "outputId": "63658ab4-ed77-46fb-843f-47d0e8eb4bfa"
      },
      "source": [
        "hdd_pipe = nlp.load(path=stored_model_path)\n",
        "\n",
        "preds = hdd_pipe.predict('I hate the newest update')\n",
        "preds"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                   document  \\\n",
              "0  I hate the newest update   \n",
              "\n",
              "                        sentence_embedding_from_disk sentiment  \\\n",
              "0  [-0.3084234893321991, -0.1103060245513916, 0.1...  negative   \n",
              "\n",
              "  sentiment_confidence  \n",
              "0                  2.0  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-08cdde45-d082-4ff5-b3aa-fb14cfbaeb3e\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>document</th>\n",
              "      <th>sentence_embedding_from_disk</th>\n",
              "      <th>sentiment</th>\n",
              "      <th>sentiment_confidence</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>I hate the newest update</td>\n",
              "      <td>[-0.3084234893321991, -0.1103060245513916, 0.1...</td>\n",
              "      <td>negative</td>\n",
              "      <td>2.0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-08cdde45-d082-4ff5-b3aa-fb14cfbaeb3e')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-08cdde45-d082-4ff5-b3aa-fb14cfbaeb3e button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-08cdde45-d082-4ff5-b3aa-fb14cfbaeb3e');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 12
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "e0CVlkk9v6Qi",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "60215391-eb4e-42c0-94ff-51e4dedbe5fe"
      },
      "source": [
        "hdd_pipe.print_info()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The following parameters are configurable for this NLU pipeline (You can copy paste the examples) :\n",
            ">>> component_list['document_assembler'] has settable params:\n",
            "component_list['document_assembler'].setCleanupMode('shrink')                                    | Info: possible values: disabled, inplace, inplace_full, shrink, shrink_full, each, each_full, delete_full | Currently set to : shrink\n",
            ">>> component_list['bert_sentence_embeddings@sent_small_bert_L12_768'] has settable params:\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setBatchSize(8)               | Info: Size of every batch | Currently set to : 8\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setCaseSensitive(False)       | Info: whether to ignore case in tokens for embeddings matching | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setDimension(768)             | Info: Number of embedding dimensions | Currently set to : 768\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setMaxSentenceLength(128)     | Info: Max sentence length to process | Currently set to : 128\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setEngine('tensorflow')       | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setIsLong(False)              | Info: Use Long type instead of Int type for inputs buffer - Some Bert models require Long instead of Int. | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setStorageRef('sent_small_bert_L12_768')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L12_768\n",
            ">>> component_list['sentiment_dl@sent_small_bert_L12_768'] has settable params:\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setThreshold(0.6)                         | Info: The minimum threshold for the final result otheriwse it will be neutral | Currently set to : 0.6\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setThresholdLabel('neutral')              | Info: In case the score is less than threshold, what should be the label. Default is neutral. | Currently set to : neutral\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setEngine('tensorflow')                   | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setClasses(['positive', 'negative'])      | Info: get the tags used to trained this SentimentDLModel | Currently set to : ['positive', 'negative']\n",
            "component_list['sentiment_dl@sent_small_bert_L12_768'].setStorageRef('sent_small_bert_L12_768')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L12_768\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "cbwS4bE0uT7d"
      },
      "source": [],
      "execution_count": null,
      "outputs": []
    }
  ]
}